package org.youyun56.gpsserver.common;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {

    private final static SimpleDateFormat FULL_SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private final static SimpleDateFormat SHORT_SDF = new SimpleDateFormat("yyyy-MM-dd");

    public static String formatFull(Date date) {
        return FULL_SDF.format(date);
    }

    public static String formatShort(Date date) {
        return SHORT_SDF.format(date);
    }

    public static Date date(int year, int month, int day) {
        return date(year, month, day, 0, 0, 0);
    }

    public static Date date(int year, int month, int day, int hour, int minute, int second) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, day, hour, minute, second);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }

    public static String getDateTime() {
        // TODO Auto-generated method stub
        return FULL_SDF.format(new Date());
    }

}